package com.ruoyi.business.service;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bizsys.domain.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author:
 * @Date: 2021/3/1 10:43 上午
 */
public interface IBRepaymentService {

    //跑批任务获取账户列表
    public List<CreditAccount> getBatchRepaymentAccount(int startLimit, int step);

    public List<CreditAccount> getBatchRepaymentAccount();

    //批量代扣涉及客户数
    public int getBatchRepaymentCustCount();

    //批量代扣根据客户
    public void doBatchRepaymentByAccount(CreditAccount account,int type);

    //根据借据获取还款中的记录数
    public Integer getInRepaymentCountByLoan(String loanSerialNo);

    /**
     * 创建ussd还款方式
     *
     * @param loanIou
     * @return
     */
    Map<String, Object> createUSSD(LoanIou loanIou);

    /**
     * 通过银行卡生成ussdpamentcode
     *
     * @param transactionReference
     * @param accountDetailsBankCode
     * @return
     */
    String getUssdpaymentForBank(String transactionReference, String accountDetailsBankCode);

    /**
     * 轮询查找ussd、card还款方式订单状态
     *
     * @param paymentReference
     * @param transactionReference
     */
    void getTransactionStatus(String paymentReference, String transactionReference);

    /**
     * 判断ussd、card还款方式订单是否完成
     *
     * @param paymentReference
     * @param transactionReference
     * @return
     */
    boolean checkTransactionIsSuccess(String paymentReference, String transactionReference);

    /**
     * 创建transferToUs还款方式
     *
     * @param loanIou
     * @return
     */
    Map createTransferToUs(LoanIou loanIou);

    /**
     * 提交transferToUs还款方式
     *
     * @param repaymentTransfer
     */
    void submitTransferToUs(RepaymentTransfer repaymentTransfer);

    /**
     * 获取全部虚拟账户订单并且自动入库新增记录，返回是否有新增记录
     *
     * @param accountReference
     * @return
     */
    boolean getAllReservedAccountOrder(String custNo);

    /**
     * 创建card还款方式
     *
     * @param loanIou
     * @return
     */
    JSONObject createCard(LoanIou loanIou);

    /**
     * 提交card还款方式
     *
     * @param paymentReference
     * @param transactionReference
     */
    void submitCard(RepaymentOrder repaymentOrder, String paymentReference, String transactionReference);

    /**
     * 提交ussd还款方式
     *
     * @param paymentReference
     * @param transactionReference
     */
    void submitUssd(String paymentReference, String transactionReference);

    /**
     * transferToUs、card、ussd还款方式冲账的方法
     *
     * @param amountPaid
     */
    void transactionStatusSuccess(RepaymentOrder repaymentOrder, BigDecimal amountPaid, Date time,String reduceSource);

    void transactionStatusSuccess(LoanIou loanIou, RepaymentOrder repaymentOrder, BigDecimal amountPaid, Date time,String reduceSource);

    void overflowRepayment(RepaymentOrder repaymentOrder,CreditAccount creditAccount);

    /**
     * 线下冲账
     *
     * @param loanIou
     * @param payTime
     * @param amount
     */
    LoanIou submitOffline(LoanIou loanIou, Date payTime, BigDecimal amount, String reqParam);

    List<RepaymentOrder> getToActionTypeAndLoanSerialNo(String actionType, String loanSerialNo);

    void closeByRepayemntNo(String paymentReference);

    RepaymentOrder getMaxPayTime(String loanSerialNo);

    RepaymentOrder initRepaymentOrderToLoanIou(LoanIou loanIou, String actionType, BigDecimal amount);
//
//    void deferredWithholdingLock(RepaymentOrder repaymentOrder,Boolean isSuccess);

    ExtMonnifyReservedAccounts checkAccountReference(String custNo);

    boolean checkAmountLock(LoanIou iou,String reduceSource);

    boolean checkAmount(LoanIou iou,String reduceSource);

    void deferredWithholdingSuccess(RepaymentOrder repaymentOrder);

    void deferredWithholdingFail(RepaymentOrder repaymentOrder);

    void saveRepaymentException(String relationNo, String type, BigDecimal repaymentAmt, String custNo);

    void qucikRepayWithhol(RepaymentOrder repaymentOrder);

    void overflowRepaymentMq(RepaymentOrder repaymentOrder1, long creditAccountId);
}
